<?php
namespace app\home\controller;
use think\captcha\Captcha;
use think\Controller;
use think\Db;
use think\Request;
class Modify extends Controller{
    public function index(){
        //获取修改页面传过来的值；根据条件修改密码;
        $data["password"]=$_POST["new_password"];
        $data["mobile"]=$_POST["username"];
        $data["email"]=$_POST["username"];
        $arra=Db::table('user')->where('mobile',$data["mobile"])->whereOr('email',$data["email"])->update(["password"=>$data["password"]]);
        if($arra==1){
            $this->success('修改成功请从新登陆',"Index/login");
        }else{
            $this->error("修改失败，请从新修改","Index/modify");
        }
    }
    public function modify_b(){
        //判断是否为post提交；根据条件查询页面;
        if(Request::instance()->isPost()){
            if(Db::table('user')->where('mobile',$_POST['username'])->whereOr('email',$_POST['username'])->find() ){
                echo json_encode('false');
            }else{
                echo json_encode('true');
            }
        }
    }
    public function modify_c(){
        //判断是否为post提交；根据条件查询页面;
        if(Request::instance()->isPost()){
            if(Db::table('user')->where('mobile',$_POST['username'])->whereOr('email',$_POST["username"])->where('password',$_POST["password"])->find() ){
                echo json_encode('false');
            }else{
                echo json_encode('true');
            }
        }
    }


}
